import{p} from '../ajax.js'
var div4 = document.getElementById("iot-div4");
p("https://api-hmugo-web.itheima.net/api/public/v1/home/floordata").then((res)=>{
    return res.message;
}).then((message)=>{
    //console.log(message[0].floor_title.image_src);

    creatAndAppend("img",3)
    function creatAndAppend(name,len) {
        for(var i = 1;i<=len;i++){
            window[name+i]=document.createElement('img');
            div4.appendChild(window[name+i])
            window[name+i].src = message[i-1].floor_title.image_src;
            window[name+i].style.marginTop = "5%"
            window[name+i].style.width = "100%"
           // window[name+i].style.zIndex = "1"
            for(var j = 1;j<=5;j++){
                window[name+i+j]=document.createElement('img');
                div4.appendChild(window[name+i+j])
                window[name+i+j].src = message[i-1].product_list[j-1].image_src;
                window[name+i+j].style.width ="31%"
                window[name+i+j].style.aspectRatio = 1/1;
                window[name+i+j].style.float = "left"
                window[name+i+j].style.margin = "1%"
               // window[name+i+j].style.zIndex = "1"
            }
            window[name+i+1].style.width = "32%";
            window[name+i+1].style.aspectRatio = 1/2;
        }
    }
})